package com.it.a07test1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        //客户端：多次发送数据
        //服务器：接收多次接收数据，并打印
        //1.创建Socket对象
        Socket sokt = new Socket("127.0.0.1", 8888);
        //写出程序
        Scanner sc = new Scanner(System.in);
        OutputStream os = sokt.getOutputStream();
        while (true) {
            System.out.println("请输入你要说的话：");
            String str = sc.nextLine();
            if("886".equals(str)) {
                break;
            }
            os.write(str.getBytes());
        }
        //释放数据
        //只需要关闭客户端的链接，输出流也会同时关闭
        sokt.close();
    }
}
